package xyz.thoughtset.viewer.ai.mcp.server.entity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.util.StringUtils;
import xyz.thoughtset.viewer.common.core.entity.BaseMeta;
import xyz.thoughtset.viewer.common.crud.core.annotation.ApiCRUDPower;
import xyz.thoughtset.viewer.modules.datarel.entity.DataRel;
import xyz.thoughtset.viewer.modules.fun.entity.FunInfo;

import java.util.List;

@TableName
@Data
@AllArgsConstructor
@ApiCRUDPower(insert = false,save = true,update = false,list = true)
public class McpServerInfo extends BaseMeta {
    protected Integer typeCode;
    protected String serverTitle;
    protected String version;
    @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
    protected String baseUrl;
    protected String sseEndpoint;
    protected String messageEndpoint;
    protected Integer keepAliveInterval;
    protected String instructions;
    protected Integer requestTimeout;
//    protected Boolean immediateExecution = Boolean.FALSE;

    @TableField(exist = false)
    protected transient List<DataRel> mcpToolRels;
    @TableField(exist = false)
    private transient List<FunInfo> mcpTools;

//    public String getSseEndpoint() {
//        if (StringUtils.hasText(sseEndpoint)) return sseEndpoint;
//        else return "/sse";
//    }
//
//    public String getMessageEndpoint() {
//        if (StringUtils.hasText(messageEndpoint)) return messageEndpoint;
//        else return "/mcp/messages";
//    }
    public McpServerInfo() {
//        this.immediateExecution = null;
        this.statesCode = null;
    }

    public McpServerInfo(String serverId, Integer runningCode) {
        this();
        this.id = serverId;
        this.statesCode = runningCode;
    }
}
